{extend name="public/layout"/}
{/block}
{block name="content"}


<div class="row">
    {include file="landing/landing_left"/}

    <div class="col-md-8" style="padding-top: 70px;">
        <form class="form-horizontal" id="moduleForm" role="form" action="{:url('landing/addlanding')}" method="post">
            <div class="form-group">
                <label class="col-sm-2 control-label">落地页名</label>
                <div class="col-sm-4">
                    <input type="text" name="landing_name" value="" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">落地页title</label>
                <div class="col-sm-4">
                    <input type="text" name="landing_title" value="" class="form-control" />
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label">landing_keywords</label>
                <div class="col-sm-4">
                    <input type="text" name="landing_keywords" value="" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">落地页description</label>
                <div class="col-sm-4">
                    <input type="text" name="landing_desc" value="" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">落地页路由</label>
                <div class="col-sm-4">
                    <input type="text" name="landing_url" value="" class="form-control" />
                </div>
            </div>

            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button type="submit" class="btn btn-primary">提交</button>
                    <button class="btn btn-info" onclick="javascript:history.back(-1);return false;">返 回</button>
                </div>
            </div>
        </form>
    </div>
</div>

{/block}

{block name="script"}
{load href='_STATIC_/common/validform/css/validform.css'/}
{load href='_STATIC_/common/validform/js/validform_v5.3.2_min.js'/}
{load href='_STATIC_/common/jquery.form.min.js'/}
<script>
    $("#moduleForm").Validform({
        btnSubmit:".clicksub",
        tiptype: 3,
        ignoreHidden: true,
        callback: function(form) {
            formAjax(form, $("#moduleForm").attr("url"),function(data){
                layer.closeAll();
                if(data.code ==1){
                    layer.msg(data.msg, {icon: 1});
                }else{
                    layer.msg(data.msg, {icon: 5});
                }
            });
            return false;
        }
    });

    function formAjax(form, url,callback) {
        callback = callback ? callback : showResponse;
        $(form).ajaxSubmit({
            beforeSubmit: showRequest,
            success: callback,
            error: showError,
            url: url,
            type: "post",
            dataType: "json",
            timeout: 60000
        });
    }


    //提交前动作
    function showRequest(formData, jqForm, options) {
        click = 1;
        layer.msg('提交中，请稍后', {'time': 0, 'shade': [0.1, '#393D49'], 'icon': 16});
        $(".btnLogin").css("background", "#ccc").prop("disabled", true);
    }

    //成功后动作
    function showResponse(data) {
        layer.closeAll();
        if (data.code == 1) {
            layer.msg(data.msg,{icon:1,time:2000},function(){
                location.href=data.url;
            });
        } else {
            layer.msg(data.msg, {icon: 5, time: 1000});
        }
    }
    //错误
    function showError(XMLHttpRequest, textStatus, errorThrown) {
        layer.closeAll();
        layer.msg("状态：" + textStatus + "；出错提示：" + errorThrown, {shift: 6, icon: 5});
    }
</script>
{/block}


